package com.shhm.business.service.impl.business;

import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.shhm.business.dto.request.HistoryOrdSearchReq;
import com.shhm.business.mapper.BusiOdrHistoryMapper;
import com.shhm.business.service.business.BusiOdrHistoryService;
import com.shhm.common.dto.response.AjaxResult;
import com.shhm.common.dto.response.AjaxResultPlus;
import com.shhm.common.dto.security.SecurityUser;
import com.shhm.common.utils.ResponseUtil;
import jakarta.annotation.Resource;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

/**
 * @author JackZ
 * @version 1.0
 * @description: TODO
 * @date 2025/9/18 下午2:39
 */
@Service
public class BusiOdrHistoryServiceImpl implements BusiOdrHistoryService {
    @Resource
    private BusiOdrHistoryMapper busiOdrHistoryMapper;

    @Override
    public AjaxResult searchOrderHistory(HistoryOrdSearchReq req, Integer pageNum, Integer pageSize) {
        SecurityUser user = (SecurityUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        req.setCustomId(user.getUserId());
        return AjaxResult.success(busiOdrHistoryMapper.getHistoryOrderList(new PageDTO<>(pageNum, pageSize),req));
    }

    @Override
    public AjaxResultPlus deleteOrderHistory(String orderNum) {
        return ResponseUtil.sqlExeIsSuccess(busiOdrHistoryMapper.deleteOrderHistory(orderNum));
    }


}
